import requests
from lxml import etree

url = 'https://www.ximalaya.com/yinyue/54070700/'
header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36'
}
res = requests.get(url,headers=header)
print(res.status_code)
xhtml = etree.HTML(res.text)
yplj = xhtml.xpath("//div[@class='text Mi_']/a/@href")
print(yplj)
ypname = xhtml.xpath("//span[@class='title Mi_']/text()")
print(ypname)
for i,j in zip(yplj,ypname):
    id = i.split('/')[-1]
    murl = 'https://www.ximalaya.com/revision/play/v1/audio?id='+id+'&ptype=1'
    res = requests.get(murl,headers=header)
    newaddr = res.json()['data']['src']
    mres = requests.get(newaddr)
    data = mres.content
    filename = j.split('/')[-1]+'.mp3'
    with open(filename,'wb') as f:
        f.write(data)